<extend name="Public/base" />
<block name="style">
</block>
<block name="script">
<script src="__STATIC__/layui/layui.js"></script>
<script>
layui.use(['layer','form'], function(){
    var layer = layui.layer;
    $("#btn_generate").click(function(){
        var $url=$(this).data("url");
        $.get($url, function(result) {
            console.log(result);
            if(result.status ===1){
                var $str='<a id="generate" class="btn" href="'+result.success+'">点击访问生成代码</a>';
                if($("#generate").length!=0){
                   $("#generate").remove();
                }
                $("#container").append($str);
            }else{
                layer.open({
                    title:'生成广告代码',
                    content:result.error
                });  
            }
        })
    });
});
</script>
</block>
<block name="body">
    <div class="main-title">
        <h2> 广告【{$ad_name}】的具体内容列表</h2>
    </div>
    <div class="cf" id="container">
        <a class="btn" href="{:U('add',array('id'=>$list['id'],'ad_id'=>$ad_id,'ad_name'=>$ad_name))}">新 增</a>
        <div data-url="{:U('create_ad',array('ad_id'=>$ad_id,'ad_name'=>$ad_name))}" id="btn_generate" class="btn">生成广告代码</div>
    </div>
    <!-- 数据表格 -->
    <div class="data-table">
        <table class="table_style1">
            <thead>
                <tr class="table_header">
                    <td width="60">id</td>
                    <td>标题</td>
                    <td>描述</td>
                    <td>图片</td>
                    <td>数据地址</td>
                    <td width="100">操作</td>
                </tr>
            </thead>
            <tbody>
                <volist name="lists" id="list">
                    <tr>
                        <td>{$list.id}</td>
                        <td class="text_left">{$list.title}</td>
                        <td class="text_left">{$list.description}</td>
                        <td><img width="150" src="{$list.thumb}" /></td>
                        <td class="text_left">{$list.url}</td>
                        <td>
                            <a href="{:U('edit',array('id'=>$list['id'],'ad_id'=>$ad_id,'ad_name'=>$ad_name))}">编辑</a>
                            <a href="{:U('del',array('id'=>$list['id'],'ad_id'=>$ad_id,'ad_name'=>$ad_name))}">删除</a>
                        </td>
                    </tr>
                </volist>
            </tbody>
        </table>
    </div>
</block>
